<template>
    <div class="swiper_box">
      <div class="load" ref="load">
        <span>什么也没有 ......</span>
      </div>
      <swiper :options="swiperOption">
        <swiper-slide
          v-for="items of gg"
          :key="items.id"
          :id="items.id"
        >
          <img
            :id="items.id"
            class='swiper-img'
            :src="items.avatar"
          >
        </swiper-slide>
        <div class='swiper-pagination' slot='pagination'></div>
        <!-- <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div> -->
      </swiper>
    </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'HomeSwiper',
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        // prevButton: '.swiper-button-prev',
        // nextButton: '.swiper-button-next',
        paginationClickable: true,
        autoplayDisableOnInteraction: false,
        grabCursor: true,
        mousewheelControl: true,
        loop: true,
        autoplay: 3000,
        onTouchEnd: (swiper) => {
          var id = event.target.getAttribute('id')
          if (id) {
            this.$router.push({
              path: '/home/shownotice',
              query: {
                noticId: id
              }
            })
          }
        }
      }
    }
  },
  computed: {
    ...mapState({
      gg: 'homeImg'
    }),
    showSwiper () {
      return this.gg.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  .swiper_box >>> .swiper-pagination-bullet
    width: 17px;
    height: 17px;
  .swiper_box >>> .swiper-pagination-bullet-active
    background: white
  .swiper_box{
    float: left
    position: relative
    z-index: 0
    margin-top: .3rem
    margin-left: .3rem
    min-width: 800px
    min-height: 450px
    width: 800px
    height: 450px
    .load{
      width: 100%
      height: 100%
      position: absolute
      z-index: 1
      text-align: center
      line-height: 450px
      font-size: .6rem
      background-color: rgb(210,210,210)
      color: rgb(120,120,120)
      span{
        animation: 1.5s linear infinite load
      }
      @keyframes load{
      0%{opacity: 1}
      25%{opacity: .7}
      50%{opacity: .4}
      75%{opacity: .7}
      100%{opacity: 1}
      }
    }
    .swiper-img{
      background-color: #fff
      width: 100%
      height: 450px
    }
  }
</style>
